package com.qd.common.panda.domain.entity.space;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 承租信息
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ParkSpaceTenantDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String id;
    /**
     * 租赁开始时间
     */
    @NotBlank(message = "租赁开始时间不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "租赁开始时间长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String startDate;
    /**
     * 租赁结束时间
     */
    @NotBlank(message = "租赁结束时间不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "租赁结束时间长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String endDate;
    /**
     * 租赁开始小时
     */
    private String startHour;
    /**
     * 租赁结束小时
     */
    private String endHour;
    /**
     * 租赁天数
     */
    private Long days;
    /**
     * 实际租赁天数
     */
    private Long actualDays;
    /**
     * 车主总收益
     */
    private BigDecimal deductionTotalRevenue;
    /**
     * 车主总收益显示
     */
    private String deductionTotalRevenueDisplay;
    /**
     * 单价
     */
    private BigDecimal dayPrice;
    /**
     * 单价显示
     */
    private String dayPriceDisplay;
    /**
     * 总费用
     */
    private BigDecimal totalCost;
    /**
     * 总费用显示
     */
    private String totalCostDisplay;
    /**
     * 退款金额
     */
    private BigDecimal refundAmount;
    /**
     * 退款金额显示
     */
    private String refundAmountDisplay;
    /**
     * 扣费金额
     */
    private BigDecimal deductionAmount;
    /**
     * 扣费金额显示
     */
    private String deductionAmountDisplay;
    /**
     * 退款时间
     */
    private LocalDateTime refundTime;
    /**
     * 退款原因
     */
    @Size(max = 200, message = "退款原因长度不能超过{max}位", groups = DefaultGroup.class)
    private String refundReason;
    /**
     * 退款说明
     */
    @Size(max = 200, message = "退款说明长度不能超过{max}位", groups = DefaultGroup.class)
    private String refundNote;
    /**
     * 订单状态:0拍下未付款1付款成功2付款失败7申请退款8退款成功9退款失败
     */
    private Integer tenantOrderState;
    /**
     * 订单状态显示
     */
    private String tenantOrderStateDisplay;
    /**
     * 租赁ID
     */
    @NotBlank(message = "租赁ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "租赁ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String sid;
    /**
     * 租赁人
     */
    @Size(max = 50, message = "租赁人长度不能超过{max}位", groups = DefaultGroup.class)
    private String tenant;
    /**
     * 租赁人显示
     */
    private String tenantDisplay;
    /**
     * 下单时间
     */
    private LocalDateTime orderTime;
    /**
     * 租赁人车牌号
     */
    @NotBlank(message = "租赁人车牌号不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "租赁人车牌号长度不能超过{max}位", groups = DefaultGroup.class)
    private String tenantNumber;
    /**
     * 选择的日期列表
     */
    private List<LocalDateTime> dateList;

    @Override
    public void freeData() {
        this.id = null;
        this.startDate = null;
        this.endDate = null;
        this.startHour = null;
        this.endHour = null;
        this.days = null;
        this.actualDays = null;
        this.deductionTotalRevenue = null;
        this.deductionTotalRevenueDisplay = null;
        this.dayPrice = null;
        this.dayPriceDisplay = null;
        this.totalCost = null;
        this.totalCostDisplay = null;
        this.refundAmount = null;
        this.refundAmountDisplay = null;
        this.deductionAmount = null;
        this.deductionAmountDisplay = null;
        this.refundTime = null;
        this.refundReason = null;
        this.refundNote = null;
        this.tenantOrderState = null;
        this.tenantOrderStateDisplay = null;
        this.sid = null;
        this.tenant = null;
        this.tenantDisplay = null;
        this.orderTime = null;
        this.tenantNumber = null;
        Optional.ofNullable(dateList).ifPresent(List::clear);
        super.freeData();
    }
}
